package cn.gtlc;


import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Demo{


    /**
     * 姓名
     */
    private String name;
    /**
     * 密码
     */
    private String pwd;

    /**
     * 用户地址
     */
    private String address;

    /**
     * 构造
     */
    public Demo() {
    }

    public Demo(String name, String pwd, String address) {
        this.name = name;
        this.pwd = pwd;
        this.address = address;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return pwd
     */
    public String getPwd() {
        return pwd;
    }

    /**
     * 设置
     * @param pwd
     */
    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    /**
     * 获取
     * @return address
     */
    public String getAddress() {
        return address;
    }

    /**
     * 设置
     * @param address
     */
    public void setAddress(String address) {
        this.address = address;
    }

    public String toString() {
        return "Demo{name = " + name + ", pwd = " + pwd + ", address = " + address + "}";
    }

    public static void main(String[] args) {

        String ipPattern = "^((\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])$";
        Pattern pattern = Pattern.compile(ipPattern);
        String ipAddress = "192.168.0";
        Matcher matcher = pattern.matcher(ipAddress);
        boolean isMatch = matcher.matches();
        System.out.println("Is IP address valid? " + isMatch);

        System.out.println("-------------------------");

        String ipAreaPattern = "^((\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\-((\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])$";
        Pattern pattern2 = Pattern.compile(ipAreaPattern);
        String ip = "5ttr";
        Matcher matcher2 = pattern2.matcher(ip);
        boolean isMatch2 = matcher2.matches();
        boolean b = Pattern.compile(ipAreaPattern).matcher(ip).matches();
        System.out.println("b===>"+b);
        System.out.println("Is IP address valid? " + isMatch2);

    }
   
}

